<script type="text/javascript"><!--//--><![CDATA[//><!--
	var sendemail = function(){
		if ($('#to').val()==''){
			alert('TO cannot be empty');
		}else
		$('#tb').submitForm('/'+controller+'/sendemail', { detail:'', onComplete : function(){ }});
		
	}
	$(document).ready(function() {
	
		// Setup Form
		$('#tb').setupForm([
			{ name: 'protocol', type: 'text', size: 'medium', readonly:true},
			{ name: 'smtp_host', type: 'text', size: 'long', maxlength: 255, noempty:true},
			{ name: 'smtp_port', type: 'text', size: 'short', type: 'numeric', precision:0, maxlength: 255, noempty:true},
			{ name: 'smtp_timeout', type: 'text', size: 'short', type: 'numeric', precision:0, maxlength: 255, noempty:true},
			{ name: 'smtp_user', type: 'text', size: 'long', maxlength: 255, noempty:true},
			{ name: 'smtp_pass', type: 'password', size: 'long', maxlength: 255, noempty:true},
			{ name: 'to', type: 'text', size: 'long', maxlength: 255},
			{ name: 'cc', type: 'text', size: 'long', maxlength: 255},
			{ name: 'subject', type: 'text', size: 'long', maxlength: 255},
			{ name: 'message', type: 'textarea', size: 'long', maxlength: 255}
		], <?php echo json_encode($data); ?>);
		
		

        // Set Action Button
        var buttons = [
                       { label: 'Save', icon: 'save', onclick: function(){ 
									$('#tb').submitForm('/'+controller+'/ajax_post', { detail:'', onComplete : function(){  }});
							}
						}
                        ];
        setAction(buttons);
		
		

    });
	
	
//--><!]]></script>

<div id="form_master_message" style="display:none;"></div>
<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_mail" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
			<tr>
				<td width="100">Protocol</td>
                <td><input id="protocol" />
                </td>
			</tr>
			<tr>
				<td width="100">SMTP Host</td>
                <td><input id="smtp_host" />
                </td>
			</tr>
			<tr>
				<td width="100">SMTP Port</td>
                <td><input id="smtp_port" />
                </td>
			</tr>
			<tr>
				<td width="100">SMTP Timeout</td>
                <td><input id="smtp_timeout" />
                </td>
			</tr>
			<tr>
				<td width="100">SMTP User</td>
                <td><input id="smtp_user" />
                </td>
			</tr>
			<tr>
				<td width="100">SMTP Password</td>
                <td><input id="smtp_pass" />
                </td>
			</tr>
			</table>
        
		<fieldset><legend>Test Email</legend>
			<table class="tb_form" style="margin-bottom:0px">
			<tr>
				<td width="100">To</td>
                <td><input id="to" />
                </td>
			</tr>
			<tr>
				<td width="100">CC</td>
                <td><input id="cc" />
                </td>
			</tr>
			<tr>
				<td width="100">Subject</td>
                <td><input id="subject" />
                </td>
			</tr>
			<tr>
				<td width="100">Message</td>
                <td><input id="message" />
                </td>
			</tr>
			<tr>
                <td colspan="2" align="right">
                	<a href="#" class="easyui-linkbutton" onclick="sendemail(); return false;">SEND</a>
                </td>
			</tr>
			</table>
		</fieldset>
		</form>
    </div>
</div>

